package com.scope.activities;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.scope.R;
import com.scope.customViews.CustomView;
import com.scope.customViews.LabelButton;

public class TextReaderActivity extends CustomActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        mImagePath = getIntent().getStringExtra(SELECTED_PATH);
        super.onCreate(savedInstanceState);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.home, menu);
        return true;
    }

    private RelativeLayout mLayout;
    private void initializeLayout() {
        mLayout = new RelativeLayout(getApplicationContext());
        ViewGroup.LayoutParams lp =
                new ViewGroup.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
        setContentView(mLayout, lp);
    }

    private String mImagePath;
    private LabelButton mGallery;
    protected void initializeViews(Bundle savedInstanceState) {
        initializeLayout();

        mGallery = addNewButton();

        try {
            mGallery.setImageDrawable(Drawable.createFromPath(mImagePath));
        } catch (Exception e) {
            mGallery.setImageDrawable(getResources().getDrawable(R.drawable.icon_image));
        }
        mGallery.setId(1);
    }

    private LabelButton addNewButton() {
        LabelButton btn = new LabelButton(getApplicationContext());

        btn.setOrientation(CustomView.Orientation.VERTICAL);
        btn.setAccent(getResources().getColor(R.color.Green));

        RelativeLayout.LayoutParams lp =
                new RelativeLayout.LayoutParams(
                        getResources().getDimensionPixelSize(R.dimen.button_width_v_l),
                        getResources().getDimensionPixelSize(R.dimen.button_height_v_l));
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);

        mLayout.addView(btn, lp);
        return btn;
    }

    protected void positionViews() {
    }

    public void setAccent(int accent) {
        mAccent = accent;
        CustomView.StaticMethods.setAccent(mLayout, accent);
    }
}
